package c.c.b.a.b;

import c.c.b.a.b.a.e;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import javax.net.ssl.SSLSocket;

/* compiled from: ConnectionSpec */
public final class n {
    public static final l[] e;
    public static final n f;
    public static final n g = new n(new a(false));
    public final boolean a;
    public final boolean b;
    public final String[] c;
    public final String[] d;

    /* compiled from: ConnectionSpec */
    public static final class a {
        public boolean a;
        public String[] b;
        public String[] c;
        public boolean d;

        public a(boolean z) {
            this.a = z;
        }

        public a a(g... gVarArr) {
            if (this.a) {
                String[] strArr = new String[gVarArr.length];
                for (int i = 0; i < gVarArr.length; i++) {
                    strArr[i] = gVarArr[i].a;
                }
                c(strArr);
                return this;
            }
            throw new IllegalStateException("no TLS versions for cleartext connections");
        }

        public a b(String... strArr) {
            if (!this.a) {
                throw new IllegalStateException("no cipher suites for cleartext connections");
            } else if (strArr.length != 0) {
                this.b = (String[]) strArr.clone();
                return this;
            } else {
                throw new IllegalArgumentException("At least one cipher suite is required");
            }
        }

        public a c(String... strArr) {
            if (!this.a) {
                throw new IllegalStateException("no TLS versions for cleartext connections");
            } else if (strArr.length != 0) {
                this.c = (String[]) strArr.clone();
                return this;
            } else {
                throw new IllegalArgumentException("At least one TLS version is required");
            }
        }

        public a(n nVar) {
            this.a = nVar.a;
            this.b = nVar.c;
            this.c = nVar.d;
            this.d = nVar.b;
        }
    }

    static {
        l[] lVarArr = new l[]{l.m, l.o, l.n, l.p, l.r, l.q, l.i, l.k, l.j, l.l, l.g, l.h, l.e, l.f, l.d};
        e = lVarArr;
        a aVar = new a(true);
        String[] strArr = new String[15];
        for (int i = 0; i < 15; i++) {
            strArr[i] = lVarArr[i].a;
        }
        aVar.b(strArr);
        g[] gVarArr = new g[4];
        gVarArr[0] = g.TLS_1_3;
        gVarArr[1] = g.TLS_1_2;
        gVarArr[2] = g.TLS_1_1;
        gVarArr[3] = g.TLS_1_0;
        aVar.a(gVarArr);
        String str = "no TLS extensions for cleartext connections";
        if (aVar.a) {
            aVar.d = true;
            n nVar = new n(aVar);
            f = nVar;
            aVar = new a(nVar);
            aVar.a(r1);
            if (aVar.a) {
                aVar.d = true;
                return;
            }
            throw new IllegalStateException(str);
        }
        throw new IllegalStateException(str);
    }

    public n(a aVar) {
        this.a = aVar.a;
        this.c = aVar.b;
        this.d = aVar.c;
        this.b = aVar.d;
    }

    public boolean a(SSLSocket sSLSocket) {
        if (!this.a) {
            return false;
        }
        String[] strArr = this.d;
        if (strArr != null && !e.w(e.p, strArr, sSLSocket.getEnabledProtocols())) {
            return false;
        }
        strArr = this.c;
        if (strArr == null || e.w(l.b, strArr, sSLSocket.getEnabledCipherSuites())) {
            return true;
        }
        return false;
    }

    public boolean equals(Object obj) {
        if (!(obj instanceof n)) {
            return false;
        }
        if (obj == this) {
            return true;
        }
        n nVar = (n) obj;
        boolean z = this.a;
        if (z != nVar.a) {
            return false;
        }
        return !z || (Arrays.equals(this.c, nVar.c) && Arrays.equals(this.d, nVar.d) && this.b == nVar.b);
    }

    public int hashCode() {
        return this.a ? ((((527 + Arrays.hashCode(this.c)) * 31) + Arrays.hashCode(this.d)) * 31) + (this.b ^ 1) : 17;
    }

    public String toString() {
        if (!this.a) {
            return "ConnectionSpec()";
        }
        String obj;
        String[] strArr = this.c;
        Object obj2 = null;
        String str = "[all enabled]";
        if (strArr != null) {
            Object unmodifiableList;
            if (strArr != null) {
                ArrayList arrayList = new ArrayList(strArr.length);
                for (String a : strArr) {
                    arrayList.add(l.a(a));
                }
                unmodifiableList = Collections.unmodifiableList(arrayList);
            } else {
                unmodifiableList = null;
            }
            obj = unmodifiableList.toString();
        } else {
            obj = str;
        }
        String[] strArr2 = this.d;
        if (strArr2 != null) {
            if (strArr2 != null) {
                ArrayList arrayList2 = new ArrayList(strArr2.length);
                for (String a2 : strArr2) {
                    arrayList2.add(g.a(a2));
                }
                obj2 = Collections.unmodifiableList(arrayList2);
            }
            str = obj2.toString();
        }
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("ConnectionSpec(cipherSuites=");
        stringBuilder.append(obj);
        stringBuilder.append(", tlsVersions=");
        stringBuilder.append(str);
        stringBuilder.append(", supportsTlsExtensions=");
        stringBuilder.append(this.b);
        stringBuilder.append(")");
        return stringBuilder.toString();
    }
}
